.TH SPINDLE "9" "2020-08-11" "LinuxCNC Documentation" "HAL Component"
.de TQ
.br
.ns
.TP \\$1
..

.SH NAME

spindle \- Control a spindle with different acceleration and deceleration and optional gear change scaling
.SH SYNOPSIS
.HP
.B loadrt spindle [count=\fIN\fB|names=\fIname1\fB[,\fIname2...\fB]]
.SH DESCRIPTION

This component will control a spindle with adjustable 
acceleration and deceleration.
It is designed for use with non-servo spindle drives that have separate 
fwd/reverse inputs, such as DC drives and inverters.
If a spindle encoder is available it is used to tailor the acceleration and 
deceleration to the spindle load.
If not the spindle speed is simulated. The component allows for gearboxes with 
up to 16 gears. Each gear has individual control of speeds, acceleration, 
driver gain and direction.
.SH FUNCTIONS
.TP
\fBspindle.\fIN\fB\fR (requires a floating-point thread)

.SH PINS
.TP
.B spindle.\fIN\fB.select-gear\fR u32 in \fR
Select a gear. Must be in the range 0 -> number of available gears  -1.
If you use this, do not use the select.x input pins.
.TP
.B spindle.\fIN\fB.commanded-speed\fR float in \fR
Commanded spindle speed (in RPM)
.TP
.B spindle.\fIN\fB.actual-speed\fR float in \fR
Actual spindle speed from a spindle encoder (in 
RPS)
If you do not have a spindle encoder set the simulate_encoder parameter to 1
.TP
.B spindle.\fIN\fB.simulate-encoder\fR bit in \fR
If you do not have an encoder, set this to 1
.TP
.B spindle.\fIN\fB.enable\fR bit in \fR
If FALSE, the spindle is stopped at the gear's maximum deceleration
.TP
.B spindle.\fIN\fB.spindle-lpf\fR float in \fR
Smooth the spindle-rpm-abs output when at speed. 0 = disabled.
Suitable values are probably between 1 and 20 depending on how stable your spindle is
.TP
.B spindle.\fIN\fB.spindle-rpm\fR float out \fR
Current spindle speed in RPM.+ve = forward, -ve = reverse.
Uses the encoder input if available. If not, uses a simulated encoder speed.
.TP
.B spindle.\fIN\fB.spindle-rpm-abs\fR float out \fR
Absolute spindle speed in RPM. Useful for spindle speed displays
.TP
.B spindle.\fIN\fB.output\fR float out \fR
Scaled output
.TP
.B spindle.\fIN\fB.current-gear\fR u32 out \fR
Currently selected gear.
.TP
.B spindle.\fIN\fB.at-speed\fR bit out \fR
TRUE when the spindle is at speed
.TP
.B spindle.\fIN\fB.forward\fR bit out \fR
TRUE for forward rotation
.TP
.B spindle.\fIN\fB.reverse\fR bit out \fR
TRUE for reverse rotation. Both forward and reverse are false when the spindle is stopped.
.TP
.B spindle.\fIN\fB.brake\fR bit out \fR
TRUE when decelerating
.TP
.B spindle.\fIN\fB.zero-speed\fR bit out \fR
TRUE when the spindle is stationary
.TP
.B spindle.\fIN\fB.limited\fR bit out \fR
TRUE when the commanded spindle speed is >max or <min.
.SH NOTES


.TP
.B The following pins are created depending the 'gears=' parameter.
One of each pin is created for each gear. If no gears are specified then one
gear will be created. For instance if you have gears=1 on your command line,
you will have  two scale pins:
 \fBspindle.\fP\fIN\fB.scale.0\fP
 \fBspindle.\fP\fIN\fB.scale.1\fP

.TP
\fBspindle.\fP\fIN\fB.scale.\fPx float in
Scale the output. For multiple gears you would use a different scale for each 
gear. If you need to reverse the output for some gears, use a negative scale.

.TP
\fBspindle.\fP\fIN\fB.min.\fPx float in
Set the minimum speed allowed (in RPM). The limit output will be TRUE while the 
commanded speed is between 0 RPM and the min speed.

.TP
\fBspindle.\fP\fIN\fB.max.\fPx float in
Set the maximum speed allowed (in RPM). The limit output will be TRUE while the 
commanded speed is above this value

.TP
\fBspindle.\fP\fIN\fB.accel.\fPx float in
Set the maximum acceleration. If you do not have a spindle encoder this is in 
RPM/second. If you do have an encoder the output is the actual speed plus this 
value. This way the acceleration can be dependent on the spindle load.

.TP
\fBspindle.\fP\fIN\fB.decel.\fPx float in
Set the minimum deceleration. If you do not have a spindle encoder this is in 
RPM/second. If you do have an encoder the output is the actual speed minus this 
value.

.TP
\fBspindle.\fP\fIN\fB.speed-tolerance.\fPx float in
Tolerance for 'at-speed' signal (in RPM). Actual spindle speeds within this 
amount of the commanded speed will cause the at-speed signal to go TRUE.

.TP
\fBspindle.\fP\fIN\fB.zero-tolerance.\fPx float in
Tolerance for 'zero-speed' signal (in RPM).

.TP
\fBspindle.\fP\fIN\fB.offset.\fPx float in
The output command is offset by this amount (in RPM).

.TP
\fBspindle.\fP\fIN\fB.select.\fPx bit in
Selects this gear. If no select inputs are active, gear 0 is selected. If 
multiple select inputs are active the highest is selected.

.SH LICENSE

GPL
